<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class AttrValue extends Model
{
    protected $table = 'attr_value';

    protected $primaryKey = 'attr_id';

    public $timestamps = false;
    //白名单
    protected $fillable = [
        'attr_id', //主键
        'attribute_id', //关联店铺属性表ID
        'back_style', //后台显示样式
        'front_style', //前端显示样式
        'icon', //图标
        'order', //排序
        'is_show', //是否显示 1为显示 2为未显示
        'icon_oss',
    ];

    protected $casts = ['icon'];

    public function getIconAttribute($value)
    {
        return \App\Library\HandleFile::handleFilePath($value, $this->icon_oss);
    }

    //关联店铺属性
    public function attribute()
    {
        return $this->hasOne('App\\Models\\Attribute', 'attribute_id', 'attribute_id');
    }

    //关联店铺属性关联表
    public function shop_attribute()
    {
        return $this->hasOne('App\\Models\\ShopAttribute', 'attr_id', 'attr_id');
    }
}
